package com.andnnl.consumer;

import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

/**
 * Created by chenss on 2021/3/11.
 */
public class ConsumerTest {
    public static void main(String[] args) {


        List<String> data = Arrays.asList("1234", "2345", "abc", "def", "fhis", "253aas", "slkda", "vasd", "98asda");
        ConsumerTest.subListByCount(data, 3, (s) -> {
            System.out.println(s);
        });
        ConsumerTest.subListByCount2(data, 3, (s) -> {
            System.out.println(s);
        });
    }

    public static <T> void subListByCount(List<T> data, int count, Consumer<List<T>> output) {
        output.accept(data);
    }

    public static <T> void subListByCount2(List<T> data, int count, Consumer<T> output) {
        for (T datum : data) {
            output.accept(datum);
        }
    }

}
